﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using MaxLeaf.Common;
using System.Data;
using MaxLeaf.DB;

namespace MaxLeaf.DAL
{
    public class t_UnitGroupDALBuilder : BaseDALBuilder
    {
        
        public t_UnitGroupDALBuilder():base()
        {
            K2KDAL = new K2K.t_UnitGroupDAL();

            K2WDAL = new K2W.t_UnitGroupDAL();

        }

        protected override bool ValidCheck(ServerInfo orgServer, ServerInfo destServer, DataRowView drvLog)
        {
            if (CvtFunc.ToInt(drvLog[DEL.LogDEL.LogStatus]) == (int)LogStatus.Delete)
            {
                return true;
            }
            //if (destServer.Type == ServerType.Web)
            //{
            //    //只分发k3
            //    LogManager.Debug(string.Format("{0} 不分发   ", destServer));
            //    return false;
            //}
            //if (destServer.Type == ServerType.K3)
            //{
            //    using (DBAccess dbOrgCon = new DBAccess(orgServer))
            //    {
            //        DataRow drOrgData = dbOrgCon.GetTableDataFirstRow("t_UnitGroup", new Dictionary<string, object>() { { "FitemID", drvLog[DEL.LogDEL.KeyValue] } }, "Fnumber");
            //        if (drOrgData == null)
            //        {
            //            LogManager.Debug(string.Format("FitemID {0} 不是客户", drvLog[DEL.LogDEL.KeyValue]));
            //            return false;
            //        }
            //        string strItemParentFnumber = CvtFunc.ToString(drOrgData["Fnumber"]);
            //        if (strItemParentFnumber.StartsWith("9."))
            //        {

            //            LogManager.Debug(string.Format("Fnumber {0} 不分发", drOrgData["Fnumber"]));
            //            return false;

            //        }


            //    }
            //}

            return base.ValidCheck(orgServer,destServer, drvLog);
        }
        protected override bool ValidCheckOrgData(ServerInfo orgServer, DataRowView drvLog)
        {
            if (!orgServer.MasterDB)
            {
                //主账套分发
                LogManager.Debug(string.Format("{0} MasterDB {1}   ", orgServer,orgServer.MasterDB));
                return false;
            }
            if (CvtFunc.ToInt(drvLog[DEL.LogDEL.LogStatus]) == (int)LogStatus.Delete)
            {
                return true;
            }
             
            return base.ValidCheckOrgData(orgServer, drvLog);
        }

        

        
    }
}